/**
 * @author LKQ
 * @date 2021/12/29 15:45
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        char[] s = {'h', 'e', 'l', 'l', 'o'};
        solution.reverseString2(s);
    }

    public void reverseString(char[] s) {
        int n = s.length, l = 0, r = n-1;
        while (l < r) {
            char temp = s[r];
            s[r] = s[l];
            s[l] = temp;
            l++;
            r--;
        }
    }

    public void reverseString2(char[] s) {
        int n = s.length, l = 0;
        while (l < n / 2) {
            char temp = s[n - l - 1];
            s[n - l - 1] = s[l];
            s[l] = temp;
            l++;
        }
    }
}
